/*
 * @Author: your name
 * @Date: 2021-07-13 18:21:11
 * @LastEditTime: 2021-07-14 21:10:52
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \TEST\Core\mycode\duoji.c
 */
#include "servo.h"
#include "usart.h"
SERVO servo1 = {90,0,90,1500};
SERVO servo2 = {90,0,90,1500};
/**
 * @description: 设置舵机的角度
 * @param {float} angle
 * @return {*}
 */
void servo1_move_to_angle(float angle)
{
    if(angle>=0&&angle <= 180)
    {
        servo1.target_angle = angle;
        servo1.pwm = (int)((angle -90)/180*1500+1500);
        // printf("%d",servo1.pwm);
	    TIM8->CCR1 = servo1.pwm;
    }
}
void servo2_move_to_angle(float angle)
{
    if(angle>=0&&angle <= 180)
    {
        servo2.target_angle = angle;
        servo2.pwm = (int)((angle -90)/180*1500+1500);
        // printf("%d",servo2.pwm);
	    TIM8->CCR2 = servo2.pwm;
    }
}


